package com.study.servlet;

import com.study.dao.LogDao;
import com.study.dao.impl.LogDaoImpl;
import com.study.util.GsonHelper;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.Timestamp;

public class BaseServlet extends HttpServlet {
    private LogDao logDao=new LogDaoImpl();
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
        logDao.insertLog("操作人:"+GsonHelper.toJsonWithTime(req.getSession().getAttribute("CURRENTCUS"))+"\t"+"请求的URL:"+req.getServletPath()+
                "\t请求的参数:"+GsonHelper.toJsonWithTime(req.getParameterMap()),new Timestamp(System.currentTimeMillis()));
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    }
}
